import Vue from "vue"
import Vuex from "vuex"
// 自定义弹窗
export default function initModal(v) {
    // 挂在store到全局Vue原型上
    v.prototype.$modalStore = new Vuex.Store({
        state: {
            show: false,
        },
        mutations: {
            hideModal(state) {
                state.show = false
            },
            showModal(state, data) {
                state = Object.assign(state, data)
                state.show = true
            },
        },
    })
    v.prototype.$showModal = function (option) {
        if (typeof option === "object") {
            v.prototype.$modalStore.commit("showModal", option)
        } else {
            throw "配置项必须为对象传入的值为：" + typeof option
        }
    }
}
